<%@page session="false" contentType="text/html" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>

<h:panelGroup>
<fieldset><legend>Dane sprzedawcy </legend>
<table cellspacing="2" cellpadding="0" border="0" width="100%">
    <tr>
        <td>
        	<tr:outputText value="Imię:"/>
        </td>
        <td>
            <tr:inputText id="firstName" value="#{salesmanBean.personid.firstname}"
            				simple="true"
            			  inlineStyle="width:250px" shortDesc="FirstName" required="true" />
        	<tr:message for="firstName" styleClass="validation_info"/>
        </td>
        <td>
        	<tr:selectBooleanCheckbox selected="#{salesmanBean.inactive}" label="Nieaktywny:" />
        </td>
    </tr>
    <tr>
        <td>
        	<tr:outputText value="Nazwisko:"/></td>
        <td colspan="2">
            <tr:inputText id="surname" value="#{salesmanBean.personid.surname}" simple="true"
            			 required="true" inlineStyle="width:250px"/>
        <tr:message for="surname" styleClass="validation_info"/></td>
    </tr>
    <tr>
        <td>
        <h:outputText value="email:"/></td>
        <td colspan="2">
            <tr:inputText id="email" value="#{salesmanBean.personid.email}" simple="true"
            				required="true" inlineStyle="width:250px">
                <f:validator validatorId="EmailValidator"/>
            </tr:inputText>
        <h:message for="email" styleClass="validation_info"/></td>
    </tr>

    <tr>
        <td>
            <tr:outputText value="Login:"/>
        </td>
        <td colspan="2">
            <tr:inputText id="login" value="#{salesmanBean.login}"
            			simple="true" shortDesc="Login" required="true" inlineStyle="width:250px"/>
            <tr:message for="login" styleClass="validation_info"/>
        </td>
    </tr>
    <tr>
        <td>
            <tr:outputText rendered="#{empty salesmanBean.id}" value="hasło:"/>
        </td>
        <td colspan="2">
            <tr:inputText rendered="#{empty salesmanBean.id}" simple="true" id="password" value="#{salesmanBean.password}" 
            			 shortDesc="Hasło" required="true" inlineStyle="width:250px" />
            <tr:message for="password" styleClass="validation_info"/>
        </td>
    </tr>
    <tr>
        <td align="left" colspan="2">
            <tr:selectManyShuttle readOnly="#{not currentUserTO.currentSalesman.permissionMap.GRANT_PERMS}"
            						id="simplePickList" value="#{salesmanBean.permissionsList}" valueChangeListener="#{salesmanController.changePermissionsListener}" >
                    <f:selectItems value="#{ConstantDictionaries.allPermissions}"/>
                    <f:converter converterId="PermissionConverter"/>
            </tr:selectManyShuttle>
        </td>
    </tr>
    <tr>
        <td align="left">
        </td>
        <td align="right"  colspan="2">
            <tr:commandButton action="dialog:change_password"  inlineStyle="margin-right:3px"
                              text="Zmień hasło" useWindow="true" partialSubmit="true"
                              rendered="#{salesmanBean.id == currentUserTO.currentSalesman.id or
                              				currentUserTO.currentSalesman.permissionMap.SALESMAN_EDIT}"
                              blocking="true" windowHeight="100" windowWidth="450"/>
            <tr:commandButton action="#{salesmanController.addSalesman}"
            				  rendered="#{salesmanBean.id == currentUserTO.currentSalesman.id or 
            				  				currentUserTO.currentSalesman.permissionMap.SALESMAN_EDIT}"
                              text="Zapisz" inlineStyle="background-color:green"/>

        </td>
    </tr>
</table>

</fieldset>
</h:panelGroup>
